package com.imti.mall.product.mapper;

import com.imti.mall.model.cms.vo.CmsSubjectVo;
import com.imti.mall.model.pms.pojo.PmsBrand;
import org.apache.ibatis.jdbc.SQL;

/**
 * ClassName: CmsSubjectCms
 * Description:
 * date: 2022/9/23 9:15
 *
 * @author: youhun
 * @version:
 * @since JDK 1.8
 */
public class CmsSubjectDynaSqlProvider {

    /**
     * 动态查询商品品牌表的
     * @param cmsSubjectVo
     * @return
     */
    public String findCmsSubjectByKeyword(CmsSubjectVo cmsSubjectVo){
        return new SQL(){
            {
                SELECT(" id,category_id,title,pic,product_count,recommend_status,create_time,collect_count,read_count,comment_count,album_pics,description,show_status,content,forward_count,category_name ");
                FROM(" `cms_subject` ");
                StringBuffer sb=new StringBuffer();
                if(cmsSubjectVo!=null) {
                    //按照是否为品牌制造商查找
                    if (cmsSubjectVo.getKeyword()!= null) {
                        sb.append(" and  title LIKE concat('%',#{keyword},'%')");
                    }
                }
                WHERE(" 1=1 "+sb.toString());
            }
        }.toString();
    }
}
